<?php

namespace Home\Controller;

/**
 * 公共控制器
 */
class CommonController extends HomeController{

    /**
     * 发送手机验证码
     * @ApiMethod   (POST)
     * @param int $mobile 手机号码
     * @param string $event 事件
     */
    public function sendSms(){
        $mobile = I('mobile','','trim');
        $event = I('event');

        $result = send_sms($mobile,$event);
        // return json($result);
        if($result['code'] == 1){
            $this->showSuccess($result['msg']);

        }else{
            $this->showError($result['msg']);
        }
    }

    /**
     * 检验手机验证码
     * @ApiMethod (POST)
     * @param int $mobile 手机号
     * @param int $code 验证码
     * @param string $event 事件
     */
    public function checkCode(){
        $mobile = I('mobile','','trim');
        $code = I('code');
        $event = I('event');

        $smsLogic = new \Common\Model\SmsLogic();
        $result = $smsLogic->checkCode($mobile,$code,$event);
        // return json($result);
        if($result['code'] == 1){
            $this->showSuccess($result['msg']);

        }else{
            $this->showError($result['msg']);
        }

    }

    /**
     * 发送短信通知
     * @ApiMethod (POST)
     * @param int $mobile 手机号
     * @param string $content 短信内容
     */
    public function sendSmsNotice(){
        $mobile = I('mobile/d','','trim');
        $content = I('content');

        $result = sms_notice($mobile,$content);
        if($result['code'] == 1){
            $this->showSuccess($result['msg']);

        }else{
            $this->showError($result['msg']);
        }
    }

}